
Imports cmplib01


Public Class frmSplitNewBG
    Private ptrParent As BattlegroupChit
    Private ptrMembers As ChitMembers
    Private ptrCGD As CampaignerGameData
    Private _newBG As New BattlegroupChit


    Public Shadows Sub showDialog(ByRef cgd As CampaignerGameData, ByRef parent As BattlegroupChit, ByRef members As ChitMembers)
        picIcon.Image = parent.icon

        ptrCGD = cgd
        ptrParent = parent
        ptrMembers = members

        MyBase.ShowDialog()

    End Sub

    Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click

        '// make it all soooo

        Try
            _newBG.icon = picIcon.Image
            _newBG.Name = txtBGName.Text
            _newBG.Status = GroundUnitStatus_cgd.Assembling
            _newBG.OwningFaction = ptrParent.OwningFaction
            _newBG.OwningPlayer = ptrParent.OwningPlayer
            _newBG.members = ptrMembers

            If ptrParent.members.Count = 0 Then ptrParent.Status = GroundUnitStatus_cgd.Disbanded

            _newBG.calculateProperties()
            _newBG.Location = New Point(ptrParent.Location.X + 3, ptrParent.Location.Y + 3)
            _newBG.deployedpointvalue = _newBG.SuggestedPointValue
            ptrCGD.Chits.add(_newBG)

            '// check to see if the parent group is empty, if it is, disband it
            If ptrParent.members.Count = 0 Then
                ptrParent.Status = GroundUnitStatus_cgd.Disbanded
            End If


        Catch ex As Exception
            HandleException("frmSplitNewBG", ex)
        End Try

        Me.Hide()

    End Sub

    Private Sub picIcon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles picIcon.Click
        Try
            Dim f As New OpenFileDialog
            f.Filter = "Pictures | *.bmp;*.png;*.jpg"
            f.ShowDialog()
            If Not f.FileName = "" Then
                picIcon.Image = Bitmap.FromFile(f.FileName)
            End If
        Catch ex As Exception

        End Try
    End Sub
End Class